home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig15_12.jar
/
Ch15
/
Fig15_12
/
STACK
/
Driver.cpp
next >
Wrap
C/C++ Source or Header
|
1997-11-04
|
1KB
|
52 lines
// Stack test program
#include <iostream.h>
#include "stack.h"
int main()
{
Stack<int> intStack;
cout << "Pushing integers on intStack" << endl;
for ( int i = 0; i < 5; i++ ) {
intStack.push( i ); // put items in the stack
cout << i << ' ';
}
cout << endl;
intStack.print(); // output the stack contents
cout << endl << "Popping integers from intStack" << endl;
while ( !intStack.isEmpty() )
cout << intStack.pop() << ' '; // remove items
cout << endl;
intStack.print(); // output the stack contents
Stack<char> charStack;
cout << endl << endl
<< "Pushing characters on charStack" << endl;
for ( char c = 'A'; c < 'E'; c++ ) {
charStack.push( c ); // put items in the stack
cout << c << ' ';
}
cout << endl;
charStack.print(); // output the stack contents
cout << endl << "Popping characters from charStack" << endl;
while ( !charStack.isEmpty() )
cout << charStack.pop() << ' '; // remove items
cout << endl;
charStack.print(); // output the stack contents
return 0;
}